package com.toutoushidao.ssm.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

/**
 * 
 * @author laodun
 *
 * ajax 请求的返回类型封装JSON结果
 */
//取出Json中的null值，可以加载entity的映射类上自动去除，参考User
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaseResult<T> implements Serializable {
	private static final long serialVersionUID = -4185151304730685014L;

    protected T data;
    protected Integer error;
    protected String message;

    public BaseResult(Integer error, String message, T data) {
        this.data = data;
        this.error = error;
        this.message = message;
    }

    public BaseResult(ResultEnum result, T data) {
        this.error = result.getCode();
        this.message = result.getMsg();
        this.data = data;
    }

    public BaseResult(ResultEnum result) {
        this.error = result.getCode();
        this.message = result.getMsg();
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getError() {
        return error;
    }

    public void setError(Integer error) {
        this.error = error;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
